package org.example.afree;

import java.util.Scanner;

public class Compute_the_sum_of_the_array {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入数组的长度：");
        int len = sc.nextInt();
        if (len<=0) {
            System.out.println("数组长度不能小于1");
            return;
        }
        int[] arr = new int[len];
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第"+(i+1)+"个元素：");
            sum+=sc.nextInt();
        }
        System.out.println("数组元素和为："+sum);
    }
}
